package com.csun.cmny.provider.device.phone.entity;

import lombok.Data;

/**
 * @Auther: chisj chisj@foxmal.com
 * @Date: 2019-02-19 20:06
 * @Description: the class phone message data login ack entity
 */
@Data
public class PhoneMessageDataLoginAckEntity {

    /**
     * 0X06: 登录成功(由服务端发送)
     * 消息内容: 0X99+时间(7byte)
     */

    /**
     * 消息类型
     */
    private byte msgType = PhoneConstant.PHONE_DATA_TYPE_LOGIN_ACK;

    /**
     * 回复消息
     */
    private byte dtype = (byte) 0x99;

    private byte[] dsize = new byte[]{0x09, 0x00};

    /**
     * 时间(7byte)
     * 秒--分--时--日--月--年%100--年/100
     */
    private byte[] date = new byte[7];

    public byte[] getBytes() {

        byte[] data = new byte[15];
        data[0] = PhoneConstant.PHONE_HEAD;
        data[1] = PhoneConstant.PHONE_HEAD_REQ;
        System.arraycopy(dsize, 0, data, 2, 2);
        data[4] = msgType;
        data[5] = dtype;
        System.arraycopy(date, 0, data, 6, 7);
        data[13] = PhoneConstant.PHONE_END_1;
        data[14] = PhoneConstant.PHONE_END_2;

        return data;
    }

}
